home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
021-030
/
amok24
/
dme
/
src
/
source.zoo
/
filereq.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-07-03
|
5KB
|
197 lines
/*
* ARP interface (ARPLOAD, ARPSAVE)
*/
#include "defs.h"
extern PROC *proc;
void
do_arpinsfile()
{
char file[64];
char dir[64];
char path[128];
long oldlock = CurrentDir(Ep->dirlock);
proc->pr_WindowPtr=(APTR)Ep->Win;
arp_pathname(Ep->dirlock,path,15);
file[0] = 0;
if (arpreq("INSERTFILE", file, path, Ep->Win)) {
CurrentDir(oldlock);
fixfile(file, path);
av[0] = (ubyte *)"i";
av[1] = (ubyte *)file;
do_edit();
return;
}
CurrentDir(oldlock);
}
void
do_arpload()
{
char dir[64];
char file[64];
char path[128];
long oldlock = CurrentDir(Ep->dirlock);
proc->pr_WindowPtr=(APTR)Ep->Win;
arp_pathname(Ep->dirlock,path,15);
file[0] = 0;
if (arpreq("NEWFILE", file, path, Ep->Win)) {
long newlock;
if (newlock = Lock(path, SHARED_LOCK)) {
UnLock(CurrentDir(oldlock));
Ep->dirlock = newlock;
av[0] = (ubyte *)"n";
av[1] = (ubyte *)file;
do_edit();
return;
}
}
CurrentDir(oldlock);
}
void
do_arpsave()
{
char file[64];
char dir[64];
char path[128];
long oldlock = CurrentDir(Ep->dirlock);
proc->pr_WindowPtr=(APTR)Ep->Win;
arp_pathname(Ep->dirlock,path,15);
splitpath(Ep->Name, file, dir);
if (arpreq("SAVEAS", file, path, Ep->Win)) {
CurrentDir(oldlock);
fixfile(file,path);
av[1] = (ubyte *)file;
do_saveas();
} else {
CurrentDir(oldlock);
}
}
fixfile(file,dir)
register char *file,*dir;
{
register char *ptr;
register short len = strlen(dir);
char hasdev = 0;
/*
* do we need to add a slash to the directory spec?
*/
if (len && dir[len-1] != '/' && dir[len-1] != ':') {
dir[len++] = '/';
dir[len] = 0;
}
/*
* Is file spec really a full path spec?
*/
for (ptr = file; *ptr; ++ptr) {
if (ptr[0] == ':')
hasdev = 1;
}
if (!hasdev) {
movmem(file,file+len,strlen(file)+1);
movmem(dir,file,len);
}
}
/*
* Search backwards for first ':' or '/' and split path there.
* This subroutine may appear to be coded incorrectly to a novice
* programmer. It isn't [now].
*/
splitpath(name, file, dir)
register char *name;
char *file, *dir;
{
register short i;
for (i = strlen(name); i >= 0; --i) { /* was (incorrectly) "i > 0" */
if (name[i] == ':' || name[i] == '/')
break;
}
++i;
strcpy(file, name + i);
bmov(name, dir, i);
dir[i] = 0;
}
#asm
; arpreq(hail,file,dir,window)
FAR DATA
FAR CODE
public _arpreq
public _LVOOldOpenLibrary
public _LVOCloseLibrary
public _SysBase
_LVOFileRequest equ -294
arp_name_text dc.b 'arp.library',0
fs ds.l 1 ;hailing text
ds.l 1 ;file name
ds.l 1 ;directory
ds.l 1 ;window requesting
ds.w 1 ;LONG Align, idiots! set to 0
ds.l 1 ;func for wildcards
ds.l 1 ;func to call w/intuimessages
_arpreq:
lea.l fs,A0
movem.l 4(sp),D0-D3 ;setup fields
movem.l D0-D3,(A0)
clr.w fs+16
move.l _SysBase,A6
lea.l arp_name_text,a1 ;open library
jsr _LVOOldOpenLibrary(a6)
tst.l d0
beq.s done
move.l d0,a6
lea.l fs,a0
jsr _LVOFileRequest(A6) ;call requestor
move.l D0,-(sp) ;return value
move.l A6,A1 ;CloseLibrary(arpbase)
move.l _SysBase,A6
jsr _LVOCloseLibrary(A6)
move.l (sp)+,D0 ;return value
done rts
XDEF _arp_pathname
_LVOPathName EQU -$14a
_arp_pathname: move.l _SysBase,A6
lea.l arp_name_text,a1 ;open library
jsr _LVOOldOpenLibrary(a6)
tst.l d0
beq.s end
move.l d0,a6
move.l 4(sp),d0
move.l 8(sp),a0
move.l 12(sp),d1
jsr _LVOPathName(a6)
move.l A6,A1 ;CloseLibrary(arpbase)
move.l _SysBase,A6
jsr _LVOCloseLibrary(A6)
end rts
#endasm